package giit.computerbase.action;

import giit.computerbase.server.IndexServer;
import giit.computerbase.util.Application;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * User: tum0r
 * Package Name: ${PACKAGE_NAME}
 * Time: 2018-11-29 Thursday 01:30:44
 */
public class IndexServlet extends HttpServlet {

    private int count = 0;

    protected void doPost(HttpServletRequest request, HttpServletResponse response) {
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding((String) Application.getConfig().pageConfig.get("encode"));
        response.setCharacterEncoding((String) Application.getConfig().pageConfig.get("encode"));
        IndexServer indexServer = new IndexServer();
        if (indexServer.judge()) {
            response.sendRedirect("home.jsp");
        } else {
            response.sendRedirect("init");
        }
    }
}
